home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Bus / T-Z / VCR+(app+src) Folder / Sources / doStuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-16  |  3.6 KB  |  188 lines  |  [TEXT/KAHL]

  1. #include "VCRplus.h"
  2. #define ScreenDepth(gdh)    ((*((*gdh)->gdPMap))->pixelSize)
  3. #define dragscreenmargin 4 /*for dragging windows, leave this many pixels on all sides*/
  4.  
  5. extern    DialogPtr                theDialog;
  6. extern    unsigned long            myFreeMem;
  7.  
  8. short doDlgEvt(EventRecord *evp)
  9. {
  10.         DialogPtr                whichDlg;
  11.         short                itemHit;
  12.         char                    theKey;
  13.         Rect                    myPaletteRect;
  14.         Point                    whichColor;
  15.  
  16.     if (DialogSelect( evp, &whichDlg, &itemHit ) == FALSE )
  17.         return(0);                        //    no extra work needed ,  just return
  18.  
  19.     if ( evp->what == keyDown )
  20.     {
  21.         if ( evp->modifiers & cmdKey )
  22.         {    /*command key pressed */
  23.             theKey =  evp->message & charCodeMask;
  24.             switch (theKey)
  25.             {
  26.                 case 'C':                        //    copy
  27.                 case 'c':
  28.                     SelIText(theDialog, ((DialogPeek)theDialog)->editField +1, 0, 32767);    //    select all the text
  29.                     DlgCopy(theDialog);
  30.                     ZeroScrap();
  31.                     TEToScrap();
  32.                     myFreeMem = Min(MaxBlock(), myFreeMem);
  33.                     break;
  34.                 case 'Q':                        //    quit
  35.                 case 'q':
  36.                     ExitToShell();
  37.                     break;
  38.                 case 'A':                        //    Select All
  39.                 case 'a':
  40.                     SelIText(theDialog, ((DialogPeek)theDialog)->editField +1, 0, 32767);    //    select all the text
  41.                     break;
  42.             }
  43.             return(0);
  44.                     /* don't let unwanted command-keys into DialogSelect() */
  45.         }
  46.         return(0);
  47.     }
  48.  
  49.     if (DialogSelect( evp, &whichDlg, &itemHit ) == FALSE )
  50.         return(0);                            //    no extra work needed ,  just return
  51.  
  52.     if ( whichDlg == theDialog )                //    process the interaction
  53.     {        
  54.         switch ( itemHit )
  55.         {
  56.         case ok:
  57.             ExitToShell();                    //    user said to "DO IT"
  58.             break;
  59.         case dlgENCODER:                    //    encode button
  60.             if (validateEntry(ENCODE))
  61.                 encoder();
  62.             else
  63.                 SysBeep(3);
  64.             break;
  65.         case dlgDECODER:                    //    decode button
  66.             if (validateEntry(DECODE))
  67.                 decoder();
  68.             else
  69.                 SysBeep(3);
  70.             break;
  71.         }    /* end of switch */
  72.     }
  73. }
  74.  
  75. void handledrag (EventRecord ev, WindowPtr w)
  76.  {
  77.     
  78.         Rect r;
  79.  
  80.     r = screenBits.bounds; 
  81.      r.top = r.top + MBarHeight; /*access a QuickDraw global*/
  82.      r.left = r.left + dragscreenmargin;  
  83.      r.right = r.right - dragscreenmargin;
  84.        r.bottom = r.bottom - dragscreenmargin;
  85.       DragWindow (w, ev.where, &r);   
  86.  
  87.  
  88. int    handlemouse (EventRecord ev)
  89. {
  90.  
  91.     register short whichPart;
  92.     WindowPtr w;
  93.     Boolean    isTrue;
  94.     
  95.       whichPart = FindWindow (ev.where, &w);
  96.     
  97.     if (w != nil) 
  98.     
  99.         if (w != FrontWindow ())             /*just like all other Mac programs*/
  100.         {
  101.             SelectWindow (w);
  102.             return; /*the mouse click is consumed by the bringtofront operation*/
  103.         }
  104.     
  105.     switch (whichPart)
  106.     {
  107.         case inSysWindow:
  108.             SystemClick (&ev, w); 
  109.             break;
  110.         
  111.         case inMenuBar:
  112.             return(DoCommand(MenuSelect(ev.where)));
  113.             break;
  114.             
  115.         case inDrag:
  116.             handledrag (ev, w);
  117.             break;
  118.             
  119.         case inGoAway:
  120.             isTrue = TrackGoAway (w, ev.where);
  121.             if (isTrue)
  122.                 ExitToShell();
  123.             break;
  124.             
  125.     } /*switch*/
  126. } /*handlemouse*/
  127.  
  128.  
  129.  
  130. int DoCommand(long mResult)
  131. {
  132.     int        theItem;
  133.     Str255    name;
  134.     
  135.     theItem = LoWord(mResult);
  136.     switch (HiWord(mResult))
  137.     {
  138.         case appleID:
  139.             GetItem(GetMHandle(appleID), theItem, &name);
  140.             if (theItem == 1)
  141.                 Alert(128,0L);
  142.             else
  143.             {
  144.                 OpenDeskAcc(name);
  145.                 SetPort(theDialog);
  146.             }
  147.             break;
  148.  
  149.         case fileID: 
  150.             ExitToShell();
  151.             break;
  152.  
  153.         case editID: 
  154.             if (SystemEdit(theItem-1) == 0)
  155.             {
  156.                 switch (theItem)
  157.                 {
  158.                     case cutCommand:
  159.                         DlgCut(theDialog);
  160.                         break;
  161.     
  162.                     case copyCommand:
  163.                         SelIText(theDialog, 3, 0, 32767);    //    select all the text
  164.                         DlgCopy(theDialog);
  165.                         ZeroScrap();
  166.                         TEToScrap();
  167.                         break;
  168.         
  169.                     case pasteCommand:
  170.                         DlgPaste(theDialog);
  171.                         break;
  172.         
  173.                     case clearCommand:
  174.                         DlgDelete(theDialog);
  175.                         break;
  176.         
  177.                     case selectCommand:
  178.                         SelIText(theDialog, 3, 0, 32767);    //    select all the text
  179.                         break;
  180.                 }
  181.             }
  182.             break;
  183.     }
  184.     HiliteMenu(0);
  185.     return(1);
  186. }
  187.